package com.rs.service.impl.rs;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.rs.dao.ProrateMapper;
import com.rs.model.CommonResult;
import com.rs.model.Prorate;
import com.rs.service.rs.ProrateService;

@Service
public class ProrateServiceImpl implements ProrateService {

	@Autowired
	private ProrateMapper prom;

	/**
	 * 判断数据库中比例分配是否存在
	 */
	@Override
	public void judgeProrateExist() {
		List<Prorate> list = prom.selectAll();
		if (list.size() == 0) {//新建Prorate
			Prorate prorate = new Prorate(85, 15);
			prom.insert(prorate);
		}
	}

	/*******App**********/
	/**
	 * 查询比例分配
	 */
	@Override
	public CommonResult<List<Prorate>> prorateQueryApp() {
		List<Prorate> list = prom.selectAll();
		return new CommonResult<List<Prorate>>(200, "查询成功", list);
	}

	/*******PC*******/
	/**
	 * pc查询比例分配
	 */
	@Override
	public CommonResult<List<Prorate>> prorateQueryPc() {
		List<Prorate> list = prom.selectAll();
		return new CommonResult<List<Prorate>>(200, "查询成功", list);
	}

	/**
	 * pc修改比例分配
	 */
	@Override
	public CommonResult<String> prorateUpdatePc(Prorate prorate) {
		prom.updateByPrimaryKey(prorate);
		return new CommonResult<String>(200, "修改成功");
	}

}
